package src;

import static org.junit.Assert.*;
import org.junit.Test;
import junit.framework.TestCase;

/**
 * Created by ren on 2017/5/5.
 */
public class ComplexTest extends TestCase {
    Complex complex = new Complex(1, 1);

    @Test
    public void testAdd() {
        assertEquals(new Complex(3.3, 3.4), complex.ComplexAdd(new Complex(2.3, 2.4)));
        assertEquals(new Complex(3.2, 2.5), complex.ComplexAdd(new Complex(2.2, 1.5)));//新增1
    }

    //测试加法
    @Test
    public void testSub() {
        assertEquals(new Complex(-5.3, -2.4), complex.ComplexSub(new Complex(6.3, 3.4)));
        assertEquals(new Complex(-3.3, -1.1), complex.ComplexSub(new Complex(4.3, 2.1)));//新增2
    }

    //测试减法
    @Test
    public void testMulti() {
        assertEquals(new Complex(3.0, 2.0), complex.ComplexMulti(new Complex(3.0, 2.0)));
        assertEquals(new Complex(2.5, 4.3), complex.ComplexMulti(new Complex(2.5, 4.3)));//新增3
    }

    //测试乘法
    @Test
    public void testDiv() {
        assertEquals(new Complex(1.0, 1.0), complex.ComplexDiv(new Complex(1.0, 1.0)));
        assertEquals(new Complex(0.0, 0.0), complex.ComplexDiv(new Complex(1.0, 0.0)));
        assertEquals(new Complex(0.6, 0.2), complex.ComplexDiv(new Complex(2.0, 1.0)));//新增4
        //assertEquals(new Complex(0.0,0.0), complex.ComplexDiv(new Complex(3,4)));
        //边缘测试
    }

    //测试除法
    @Test
    public void testequals() {

        assertEquals(true, complex.equals(new Complex(1.0, 1.0)));
    }
//测试判断相等
}
